<template>
  <div class="index" v-if="initFinish">
    <div class="title-img">
      <img mode="widthFix" src="../../static/images/index/index-title.png" />
    </div>
    <div class="main-content">
      <div class="tip-content">
        <ScrollTip />
      </div>
      <div class="rules-content">
        <CommentRules ref="commentRules" @close="rulesClose" />
      </div>
      <div class="county-content">
        <p class="note">点击下方区县按钮进行评议：</p>
        <CountySelect />
      </div>
    </div>
    <div class="statement-content">
      <p>
        <uni-icons type="info" size="20" color="#4678b2" />
        <span>声明: 评议全程匿名且不收集任何个人信息!</span>
      </p>
    </div>
    <InitNote v-if="letterShow" @close="letterClose" />
    <UserInfoSelect v-if="userInfoSelectShow" @close="userInfoSelectShow = null" />
  </div>
</template>

<script>
  import ScrollTip from '../../components/index/scroll-tip/ScrollTip';
  import CommentRules from '../../components/index/comment-rules/CommentRules';
  import CountySelect from '../../components/index/county-select/CountySelect';
  import InitNote from '../../components/index/InitNote';
  import UserInfoSelect from '../../components/index/county-select/UserInfoSelect';
  import { checkInitFinish } from '../../utils/init';
  
  export default {
    components: {
      ScrollTip,
      CommentRules,
      CountySelect,
      InitNote,
      UserInfoSelect,
    },
    data() {
      return {
        letterShow: true,
        userInfoSelectShow: false,
        initFinish: false,
      };
    },
    onLoad() {
    },
    created() {
      this.init();
    },
    methods: {
      async init() {
        this.initFinish = await checkInitFinish();
      },
      letterClose() {
        this.letterShow = false;
        const CommentRules = this.$refs.commentRules[ 0 ] || this.$refs.commentRules;
        CommentRules.showRules(true);
      },
      rulesClose({ isShowSelectRole }) {
        if (isShowSelectRole) {
          this.userInfoSelectShow = true;
        }
      },
    },
  };
</script>

<style lang="scss" scoped>
  .index {
    padding-bottom: 45px;
    overflow: auto;
    .title-img {
      img {
        display: block;
        width: 100%;
      }
    }
    .main-content {
      background-image: linear-gradient(to bottom, #396cf6, white);
      padding-bottom: 20px;
      .tip-content {
        padding: 15px;
        ::v-deep .uni-noticebar {
          margin: 0;
          padding: 0;
        }
      }
      .county-content {
        padding: 15px;
        p {
          font-size: 12px;
          line-height: 1;
          color: #1f6cdb;
        }
      }
    }
    .statement-content {
      position: fixed;
      bottom: 0;
      left: 0;
      width: 100%;
      padding: 10px 15px;
      background-color: #f0f2f5;
      color: #4678b2;
      p {
        font-size: 12px;
        display: flex;
        align-items: center;
        line-height: 1;
        span {
          margin-left: 10px;
        }
      }
    }
  }
</style>
